package com.limespot.api.tree;

import java.awt.Font;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.limespot.api.User;

public class UserPanel extends JPanel {

	private static final long	serialVersionUID	= -4998215033030541264L;

	public UserPanel(User user) {
		JPanel left = new JPanel();
		try {
			left.add(new JLabel(new ImageIcon(new URL(user.getSmallImageURL()))));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		JPanel right = new JPanel();
		right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
		
		Font f = new JLabel().getFont();
		String bio = user.getBio();
		if (bio == null || bio.equals("")) bio = "none";
		String url = user.getURL();
		if (url == null || url.equals("")) url = "none";
		JLabel nameLabel = new JLabel(user.getName());
		JLabel urlLabel = new JLabel(url);
		JLabel bioLabel = new JLabel(bio);
		nameLabel.setFont(new Font(f.getName(), Font.BOLD, (int)(f.getSize()*1.5)));
		bioLabel.setFont(new Font(f.getName(), Font.ITALIC, f.getSize()));
		
		right.add(nameLabel);
		right.add(urlLabel);
		right.add(bioLabel);
	}
}
